package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.lang.domain.PageRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.TrainFlowHandleBO;
import com.xy.biz.ts.domain.po.TrainFlowHandlePO;
import com.xy.biz.ts.domain.query.TrainFlowHandleQuery;
import com.xy.biz.ts.domain.resp.GetTrainFlowHandleResponse;
import com.xy.biz.ts.domain.req.SaveTrainFlowHandleRequest;
import com.xy.biz.ts.domain.req.ListTrainFlowHandleRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-6-28
 */
public class TrainFlowHandleConverter {
	
	public static TrainFlowHandlePO toPO(TrainFlowHandleBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainFlowHandlePO(), true);
	}
	
	public static List<TrainFlowHandlePO> toPO(Collection<TrainFlowHandleBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainFlowHandlePO(), true);
	}
	
	public static TrainFlowHandleBO fromPO(TrainFlowHandlePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainFlowHandleBO());
	}
	
	public static List<TrainFlowHandleBO> fromPO(Collection<TrainFlowHandlePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainFlowHandleBO());
	}
	
	public static TrainFlowHandleBO toBO(SaveTrainFlowHandleRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainFlowHandleBO(), true);
	}
	
	public static List<TrainFlowHandleBO> toBO(Collection<SaveTrainFlowHandleRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainFlowHandleBO(), true);
	}
	
	public static GetTrainFlowHandleResponse toResponse(TrainFlowHandleBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetTrainFlowHandleResponse());
	}
	
	public static List<GetTrainFlowHandleResponse> toResponse(Collection<TrainFlowHandleBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetTrainFlowHandleResponse());
	}
	
	public static TrainFlowHandleQuery toQuery(ListTrainFlowHandleRequest source) {
		if(null == source) {
			return null;
		}
		TrainFlowHandleQuery target = new TrainFlowHandleQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	public static TrainFlowHandleQuery toQuery(PageRequest source) {
		TrainFlowHandleQuery target = new TrainFlowHandleQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
